<?php

 header("Content-Type:text/html;charset=utf-8");
 require 'dbcon.php';
 $username=$_REQUEST['username'];//获取用户呢称
 $content=$_REQUEST['content'];// 获取用户留言
 date_default_timezone_set('Asia/Shanghai');//设置时区
 $time=date("Y-m-d h:i:s");  //获取当前的日期时间
 $sql="insert into tb_note(username,content,time) values('{$username}', '{$content}','{$time}')";//写SQL语句
 $rs=$db->query($sql);//执行SQL语句
 if  ($rs==true)
 {
    echo "<script language='javascript' type='text/javascript'>"; 
    //echo "alert('发布成功！');";
    echo "window.location.href='index.php';";
    echo "</script>";
 }
 else {
    echo "<script language='javascript' type='text/javascript'>"; 
    echo "alert('发布失败！');";
    echo "window.location.href='index.php';";
    echo "</script>";
}
$db->close();